import request from '../request';
import qs from 'qs';

export const resoutlist = (params: user): RPS<RouterList<inRouterList>> =>
    request.get('/resource/list', { params });
// 获取菜单列表
export const menulist = (params: paramslist): RPS<menuList<inMenuList>> =>
    request.get(
        `/menu/list/${params.parentId}?pageNum=${params.pageNum}&pageSize=${params.pageSize}`
    );
//获取菜单列表数据
export const getmumunsApi = (): RPS<getmunent> => request.get('/menu/treeList');
// 添加菜单
export const addmenuApi = (params: addmenu): RPS<any> => request.post('/menu/create', params);
//根据ID获取菜单详情
export const getidmumunsApi = (params: number): RPS<getidmumuns> => request.get(`/menu/${params}`);
//修改后台数据
export const changemenuApi = (params: changemenu): RPS<any> =>
    request.post(`/menu/update/${params.id}`, params);
//修改显示状态
export const changeshowApi = (params1: number, params2: number): RPS<any> =>
    request.post(`/menu/updateHidden/${params1}?hidden=${params2}`);
//角色列表编辑
export const RoleListEditingApi = (params: RoleListEditing): RPS<any> =>
    request.post(`/role/update/${params.id}`, params);

export const loginApi = (params: ILoginParams): RPS<ILoginResponse> =>
    request.post('/admin/login', params);
//
export const userInfoApi = (): RPS<IUserInfoRespons> => request.get('/admin/info');

// 所有用户
export const getUserListApi = (params?: user): RPS<IUserListData<IUserModel>> =>
    request.get('/admin/list', { params });

//修改用户状态
export const updateUserStatusApi = (params: IUpdateUserStatusParams): RPS<any> =>
    request.post(`/admin/updateStatus/${params.id}?status=${params.status}`);

// 用户注册
export const registerUserApi = (params: IRegisterUserParams): RPS<IUserModel> =>
    request.post('/admin/register', params);

// 获取用户指定的信息
export const getuserinfo = (id: number): RPS<IUserModel> => request.get(`/admin/${id}`);

// 用户编辑
export const updateUserInfoApi = (params: IUserModel): RPS<any> =>
    request.post(`/admin/update/${params.id}`, params);

// 获取所有角色
export const getRoleListApi = (): RPS<IRoleModel[]> => request.get('/role/listAll');

// 获取指定用户的所有的角色
export const getRoleListByAdminIdApi = (adminId: number): RPS<IRoleModel[]> =>
    request.get(`/admin/role/${adminId}`);

export const updateRolesApi = ({ adminId, roleIds }: IUpdateRolesParams) => {
    // qs 在转换 数组的时候，有点和我们想要的不一样，所以这个东西，我们还是只能自己转换
    // console.log(qs.stringify(params));
    return request.post(`/admin/role/update?adminId=${adminId}&roleIds=${roleIds.join(',')}`);
};

// 分页获取 角色列表
export const queryRoleListApi = (params: user): RPS<IUserListData<IRoleModel>> =>
    request.get('/role/list', { params });

// 获取所有资源的接口
export const getAllResourceApi = (): RPS<IRourceModel[]> => request.get('/resource/listAll');

// 获取所有资源分类
export const getAllResourceCategoryApi = (): RPS<IResourceCategoryModel[]> =>
    request.get('/resourceCategory/listAll');

//获取角色相关的资源
export const getListRoleResourceApio = (roleId: number): RPS<IRourceModel[]> =>
    request.get(`/role/listResource/${roleId}`);

// 修改角色相关的资源
export const allocResourceApi = (params: IAllocResourceParams): RPS<any> =>
    request.post('/role/allocResource?' + qs.stringify(params, { arrayFormat: 'comma' }));

export const goodsClassifyApi = (params: IGoodClassParams): RPS<IUserListData<IGoodsData>> =>
    request.get(
        `/productCategory/list/${params.parentId}?pageNum=${params.pageNum}&pageSize=${params.pageSize}`
    );

export const getTheGoodListApi = (id: number): RPS<IGoodsData> =>
    request.get(`/productCategory/${id}`);

export const getGoodsAttributeApi = (): RPS<IGoodsAttributeData[]> =>
    request.get('/productAttribute/category/list/withAttr');

export const upDateTheGoodAttributeApi = (params: IGoodUpdateParams): RPS<any> =>
    request.post(`/productCategory/update/${params.id}`, params.productAttributeParam);

export const brandListApi = (params: user): RPS<IUserListData<IGoodBrand>> =>
    request.get(
        `/brand/list?keyword=${params.keyword}&pageNum=${params.pageNum}&pageSize=${params.pageSize}`
    );

export const updateFacStateApi = (params: IUpdateFacStateParams): RPS<any> =>
    request.post(`/brand/update/factoryStatus`, qs.stringify(params, { arrayFormat: 'comma' }));

export const updateShowStateApi = (params: IUpdateShowStateParams): RPS<any> =>
    request.post('/brand/update/showStatus', qs.stringify(params, { arrayFormat: 'comma' }));

export const getGoodsAttributeListApi = (params: user): RPS<IUserListData<IGoodAttribute>> =>
    request.get(
        `/productAttribute/category/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`
    );

export const createBrandApi = (params: ICreateBrandParams): RPS<any> =>
    request.post('/brand/create', params);

export const createCategoryApi = (params: IGoodsData): RPS<any> =>
    request.post('/productCategory/create', params);

export const deleteCategoryApi = (id: number): RPS<any> =>
    request.post(`/productCategory/delete/${id}`);

export const categoryChildrenApi = (): RPS<IGoodsDataWithChildren[]> =>
    request.get('/productCategory/list/withChildren');

export const getAllGoodsListApi = (
    params: IProductListParams
): RPS<IUserListData<IProductListResponse>> =>
    request.get(`/product/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`);
// request.post(
//     "/role/allocResource?" + qs.stringify(params, { arrayFormat: "comma" })
// );

// /flash/list  秒杀列表
export const flashListApi = (params: user): RPS<IUserListData<IFlashListModel>> =>
    request.get('/flash/list', { params });

// /flashSession/selectList  获取全部可选场次及其数量-->设置商品
export const selectListAApi = (params: { flashPromotionId: number }): RPS<ISelectListAApi[]> =>
    request.get('/flashSession/selectList', { params });

// /flashProductRelation/list 分页查询不同场次关联及商品信息
export const flashProductRelationApi = (
    params: IFlashProductRelation
): RPS<IUserListData<IFlashProductRelationList>> =>
    request.get('/flashProductRelation/list', { params });

// /flash/update/status/{id} 修改上下线状态

export const updateStatus = (params: IUpdateUserStatusParams): RPS<Number> =>
    request.post(`/flash/update/status/${params.id}?status=${params.status}`);

// /flashSession/list 获取全部场次
export const flashSessionList = (): RPS<IFlashSessionList[]> => request.get('/flashSession/list');

// /flashSession/update/status/{id} 修改启用状态
export const flashSessionupdateStatus = (params: IUpdateUserStatusParams): RPS<Number> =>
    request.post(`/flashSession/update/status/${params.id}?status=${params.status}`);

// /mall-admin/flashSession/update/{id} 修改场次
export const flashSessionUpdate = (params: IFlashSessionUpdate): RPS<number> =>
    request.post(`/flashSession/update/${params.id}`, params);
// /mall-admin/flashSession/delete/{id} 删除场次
export const flashSessionDelete = (id: number): RPS<any> =>
    request.post(`/flashSession/delete/${id}`);
// /mall-admin/flashSession/create 添加场次
export const flashSessionCreate = (params: IFlashSessionUpdate): RPS<number> =>
    request.post('/flashSession/create', params);
// /flash/create  添加活动
export const flashcreate = (params: IFlashListModel): RPS<number> =>
    request.post('/flash/create', params);
//  /flash/update/{id} 编辑活动
export const flashUpdate = (params: IFlashListModel): RPS<number> =>
    request.post(`/flash/update/${params.id}`, params);

// /flash/delete/{id}  删除活动
export const flashDelete = (id: number): RPS<any> => request.post(`/flash/delete/${id}`);

// /product/list 查询商品

export const productList = (params: user): RPS<IUserListData<IProductList>> =>
    request.get('/product/list', { params });

//  /flashProductRelation/create 批量选择商品添加关联
export const flashProductRelationCreate = (params: IAddList[]) =>
    request.post('/flashProductRelation/create', params);

// /home/brand/list  分页查询推荐品牌

export const homeBrandList = (params: IHomeBrandListRSQ): RPS<IUserListData<IHomeBrandList>> =>
    request.get('/home/brand/list', { params });

//  /brand/list  根据品牌名称分页获取品牌列表 选择品牌
export const brandList = (params: user): RPS<IUserListData<IBrandList>> =>
    request.get('/brand/list', { params });

// /home/brand/create 添加首页推荐品牌

export const homeBrandCreate = (params: IHomeBrandList[]): RPS<number> =>
    request.post('/home/brand/create', params);
// /home/brand/update/recommendStatus 批量修改推荐品牌状态
export const homebrandupdateRecommendStatus = (params: recommendStatus): RPS<number> =>
    request.post(
        `/home/brand/update/recommendStatus?recommendStatus=${params.recommendStatus}&` +
        qs.stringify(params, { arrayFormat: 'comma' })
    );

// /home/brand/update/sort/{id} 修改推荐品牌排序
export const homeBrandUpdateSort = (params: homeBrandUpdateSort): RPS<number> =>
    request.post(`/home/brand/update/sort/${params.id}?sort=${params.sort}&id=${params.id}`);

// /home/brand/delete 批量删除推荐品牌
export const homeBrandDelete = (params: delRecommend): RPS<number> =>
    request.post('/home/brand/delete', qs.stringify(params, { arrayFormat: 'comma' }));

// /home/advertise/list  分页查询广告

export const homeAdvertiseList = (
    params: homeAdvertiseList
): RPS<IUserListData<homeAdvertiseModel>> => request.get('/home/advertise/list', { params });
// /home/advertise/create 添加广告
export const homeAdvertiseCreate = (params: homeAdvertiseModel): RPS<number> =>
    request.post('/home/advertise/create', params);

// /home/advertise/update/status/{id} 修改上下线状态

export const homeAdvertiseUpdateStatus = (params: IUpdateUserStatusParams): RPS<number> =>
    request.post(`/home/advertise/update/status/${params.id}?status=${params.status}`);

// /home/advertise/delete  删除广告
export const homeAdvertiseDelete = (params: delRecommend): RPS<number> =>
    request.post('/home/advertise/delete', qs.stringify(params, { arrayFormat: 'comma' }));

// /home/advertise/{id}  获取广告详情
export const homeadvertise = (id: number): RPS<homeAdvertiseModel> =>
    request.get(`/home/advertise/${id}`);

// /home/newProduct/list 分页查询首页新品
export const homeNewProductList = (
    params: homeNewProductList
): RPS<IUserListData<homeNewProductListModel>> => request.get('/home/newProduct/list', { params });
// /product/list 查询商品
export const ProductList = (params: user): RPS<IUserListData<Iproduct>> =>
    request.get('/product/list', { params });

// /home/newProduct/update/recommendStatus 批量设为新品
export const productUpdateNewStatus = (params: newStatus): RPS<number> =>
    request.post(
        `/home/newProduct/update/recommendStatus`,
        qs.stringify(params, { arrayFormat: 'comma' })
    );

//  /home/newProduct/create 添加首页商品
export const homeNewProductCreate = (params: productIdCreate[]): RPS<number> =>
    request.post('/home/newProduct/create', params);

// /home/newProduct/update/sort/{id} 修改新品排序
export const homeNewProductUpdataSort = (params: homeBrandUpdateSort): RPS<number> =>
    request.post(`/home/newProduct/update/sort/${params.id}?sort=${params.sort}&id=${params.id}`);

// /home/newProduct/delete 批量删除首页新品

export const homeNewProductDelete = (params: delRecommend): RPS<number> =>
    request.post('/home/newProduct/delete', qs.stringify(params, { arrayFormat: 'comma' }));

//  /home/recommendProduct/list  分页查询推荐

export const homeRecommendProductList = (
    params: homeNewProductList
): RPS<IUserListData<subjectListmodel>> => request.get('/home/recommendProduct/list', { params });

// /home/recommendProduct/update/recommendStatus 批量修改推荐状态

export const homeRecommendProductUpdataRecommendStatus = (params: newStatus): RPS<number> =>
    request.post(
        `/home/recommendProduct/update/recommendStatus`,
        qs.stringify(params, { arrayFormat: 'comma' })
    );

//  /home/recommendProduct/update/sort/{id}  修改推荐排序

export const homeRecommendProductUpdateSort = (params: homeBrandUpdateSort): RPS<number> =>
    request.post(
        `/home/recommendProduct/update/sort/${params.id}?sort=${params.sort}&id=${params.id}`
    );

// /home/recommendProduct/delete 批量删除推荐
export const homeRecommendProductDelete = (params: delRecommend): RPS<number> =>
    request.post('/home/recommendProduct/delete', qs.stringify(params, { arrayFormat: 'comma' }));

//  /home/recommendProduct/create 添加首页推荐
export const homeRecommendProductCreate = (params: productIdCreate[]): RPS<number> =>
    request.post('/home/recommendProduct/create', params);
// /home/recommendSubject/list  分页查询推荐

export const homeRecommendSubjectList = (
    params: homeNewProductMoodel
): RPS<IUserListData<homeRecommendSubjectList>> =>
    request.get('/home/recommendSubject/list', { params });

// /home/recommendSubject/create 添加首页推荐专题
export const homeRecommendSubjectCreate = (params: subjectCreate[]): RPS<number> =>
    request.post('/home/recommendSubject/create', params);

//  /subject/list 根据专题名称分页获取专题

export const subjectList = (params: user): RPS<IUserListData<subjectListmodel>> =>
    request.get('/subject/list', { params });
// /home/recommendSubject/update/recommendStatus 批量修改推荐状态
export const homeRecommendSubjectUpdateRecommendStatus = (params: newStatus): RPS<number> =>
    request.post(
        `/home/recommendSubject/update/recommendStatus`,
        qs.stringify(params, { arrayFormat: 'comma' })
    );

// /home/recommendSubject/update/sort/{id}  修改推荐排序
export const homeRecommendSubjectUpdateSort = (params: homeBrandUpdateSort): RPS<number> =>
    request.post(
        `/home/recommendSubject/update/sort/${params.id}?sort=${params.sort}&id=${params.id}`
    );

// /home/recommendSubject/delete  批量删除推荐
export const homeRecommendSubjectDelete = (params: delRecommend): RPS<number> =>
    request.post('/home/recommendSubject/delete', qs.stringify(params, { arrayFormat: 'comma' }));

// 列表订单-陈子龙
export const listInfo = (params: list): RPS<IUserListData<getlist>> =>
    request.get('/order/list', { params });

// 批量删除订单-陈子龙
export const deleteList = (ids: number[]): RPS<any> => request.post(`/order/delete?ids=${ids}`);

// 进入页面发起请求获取订单的设置-陈子龙
export const getList = (id: number): Promise<IResponse<updatelist>> =>
    request.get(`/orderSetting/${id}`);

// 修改指定订单的设置
// export const updateList = (params: any): Promise<IResponse<any>> => request.get(`/orderSetting/update/${params.id}`)

// 获取根据优惠券名称和类型分页获取优惠券列表
export const couponListApi = (params: ICouponSearch): RPS<IUserListData<ICouponList>> =>
    request.get('/coupon/list', { params });

// 添加优惠券
export const couponCreateApi = (params: ICouponCreate): RPS<any> =>
    request.post('/coupon/create', params);

// 获取单个优惠券的详细信息
export const couponDetailed = (id: number): RPS<any> => request.get(`/coupon/${id}`);

// 删除优惠券
export const couponDeleApi = (id: number): RPS<any> => request.post(`/coupon/delete/${id}`);

// 编辑优惠券
export const couponUpdateApi = (id: number, params: ICouponList): RPS<any> =>
    request.post(`/coupon/update/${id}`, params);

// 优惠券领取记录管理
export const couponHistoryApi = (params: user): RPS<any> =>
    request.get('/couponHistory/list', { params });
// 修改指定订单的设置-陈子龙
export const updateList = (params: shu): Promise<IResponse<{}>> =>
    request.post(`/orderSetting/update/${params.id}`, params.orderSetting);

// 获取退货的内容-陈子龙
export const returnReasonlist = (params: Parames): RPS<IUserListData<returnRlist>> =>
    request.get(`/returnReason/list`, { params });

// 添加退货原因-陈子龙
export const AddreturnReason = (params: returnReason): RPS<{}> =>
    request.post(`/returnReason/create`, params);

// 修改退货的状态-陈子龙
export const updatereturnReason = (params: updatStaus): RPS<{}> =>
    request.post(`/returnReason/update/status?status=${params.status}&ids=${params.ids}`);

// 获取单个退货原因详情信息-陈子龙
export const getreturnReason = (id: number): RPS<returnReason> =>
    request.get(`/returnReason/${id}`);

// 删除退货原因-陈子龙
export const deletereturnReason = (ids: number[]): RPS<{}> =>
    request.post(`/returnReason/delete?ids=${ids}`);

//修改退货原因-陈子龙
export const updateInforeturnReason = (params: returnReason): RPS<{}> =>
    request.post(`returnReason/update/${params.id}`, params);
// export const updateInforeturnReason = (params: returnReason): RPS<{}> => request.post(`/returnReason/update/${params.id}`, params)

// 分页查询退货申请 -陈子龙
export const getreturnApply = (params: returnApply): RPS<IUserListData<getreturnApply>> =>
    request.get(`/returnApply/list`, { params });

// 批量删除退货申请-陈子龙
export const deletereturnApply = (ids: number[]): RPS<{}> =>
    request.post(`/returnApply/delete?ids=${ids}`);

// 获取退货详情-陈子龙
export const deepreturnApply = (id: number): RPS<deepgetreturnApply> =>
    request.get(`returnApply/${id}`);
// export const deepreturnApply = (id: number): RPS<deepgetreturnApply> => request.get(`/returnApply/${id}`)

// 获取获取订单详情：订单信息、商品信息、操作记录-陈子龙
export const getorderInfo = (id: number): RPS<order> => request.get(`/order/${id}`)

// 添加备注-陈子龙
export const addordernote = (params: addordnote): RPS<{}> => request.post(`/order/update/note?id=${params.id}&note=${params.note}&status=${params.status}
`)

